package com.haoran.dwz.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.haoran.dwz.config.util.DynamicProperties;
import com.haoran.dwz.rest.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@Api(tags = { "USM Conf" }, description = "统一系统配置管理", position = 0)
public class PropertiesController {
	
	@Autowired
	private DynamicProperties dynamicProperties;
	
	@ApiOperation("获取配置key的值(int类型)")
	@RequestMapping(value = "getIntConfig", method = RequestMethod.GET)
	public R getIntegerConfig(@ApiParam("属性 key") @RequestParam String key) {
		int t = dynamicProperties.getInt(key, 808);
		return R.success(t);
	}
	
	@ApiOperation("获取配置key的值(T类型)")
	@RequestMapping(value = "getConfig", method = RequestMethod.GET)
	public R getConfig(@ApiParam("服务名称 ") @RequestParam String key) {
		Integer t = dynamicProperties.getT(key, 808);
		return R.success(t);
	}
}
